Typescript aspect implements the `Compiler` interface and provides the ability to transpile files on the workspace and build components in the isolated capsules.

## Configuration - tsconfig.json

An env that uses typescript compiler can have two tsconfig.json files, one for the workspace and one for the build process.

On the workspace, the following two configurations are overridden:

```
compilerOptions.sourceRoot = <componentDir>;
compilerOptions.rootDir = '.';
```

The reason to override them is to make the source-map working on the workspace.

As a reminder, the `dists` are written into the node_modules and not in the component-dir, without the configuration above, the source-map won't have the correct `sourceRoot` and `sources` values, and as a result, the debugger won't work.

On the capsules, the following configurion is overridden:

```
compilerOptions.outDir = <CompilerOptions.distDir>
```

This is done to avoid confusion when the distDir is `x` and ts-config outDir is `y`,
in which case, the dists in the capsule are written into `y`, but other bit processes expect to find them in `x`.

# Override typescript configuration in a custom env:

When creating a new custom environment, use the following API to change the typescript compiler config.

```
useTypescript(modifiers?: UseTypescriptModifiers, tsModule: any = ts)
```

The modifiers are:

```
type UseTypescriptModifiers = {
  buildConfig?: TsConfigTransformer[];
  devConfig?: TsConfigTransformer[];
};
```

As you can see, you can customize the configuration for both: the build process and for the compilation on the workspace.

An example of a TsConfigTransformer used by `teambit/aspect` for the build process, which uses the typescript compiler only for generating the types:

```
const tsconfig = require("./tsconfig.json");

const transformer: TsConfigTransformer = (config: TypescriptConfigMutator) => {
      config
        .mergeTsConfig(tsconfig)
        .setArtifactName('declaration')
        .setDistGlobPatterns([`dist/**/*.d.ts`])
        .setShouldCopyNonSupportedFiles(false);
      return config;
    };
```

In the last example, a custom tsconfig.json was merged to the builtin tsconfig.json.

```
{
  "compilerOptions": {
    ...
    "emitDeclarationOnly": true,
    ...
  },
}
```

Some more props were changed as well to accomodate this env
